const u = new URL(window.location.origin)
const parts = u.hostname.split('.')
// （ xx.Studio .in），
if (parts.length > 2) {
  parts.shift() // 
}
const cleanHost = parts.join('.')
const cleanPath = u.pathname.replace(/\/$/, '') // 
const href = `${cleanHost}${cleanPath}`
export const API_BASE_URL = () => {
  const Url = (window.location.protocol +
    '//' +
    import.meta.env.VITE_API_HOST +
    href +
    import.meta.env.VITE_API_BASE_URL) as string
  return import.meta.env.MODE === 'development' ? import.meta.env.VITE_API_URL : Url
}
export const API_IMG_URL = () => {
  const Url = window.location.protocol + '//' + import.meta.env.VITE_API_HOST + href + import.meta.env.VITE_IMG_BASE_URL
  return import.meta.env.MODE === 'development' ? import.meta.env.VITE_IMG_URL : Url
}
